<template>
    <div>
        <el-row>
            <el-col :offset="6" :span="11">
                <h3 style="text-align: center;">提出你的问题</h3>
                <el-form ref="problem" :model="problem" label-width="110px" style="margin-top:30px">
                <el-form-item label="问题：">
                    <el-input v-model="problem.title"></el-input>
                </el-form-item>
                <el-form-item label="描述(可选)：">
                    <el-input type="textarea" :autosize="{ minRows: 8, maxRows: 14}" v-model="problem.content"></el-input>
                </el-form-item>
                <el-form-item label="所属话题：">
                      <el-select v-model="problem.topicId" filterable placeholder="请选择">
                        <el-option
                            v-for="topic in topics"
                            :key="topic.id"
                            :label="topic.topicName"
                            :value="topic.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onsubmit">提交</el-button>
                </el-form-item>
                </el-form>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import {postRequest,getRequest} from '../utils/api.js'
export default {
    name: 'Enquire',
    data() {
        return {
            problem:{
                title:'',
                content:'',
                topicId:'',
            },
            topics:[],
        };
    },

    mounted() {

        getRequest('/qa/topic/searchTopics',this.problem).then((result) => {
                this.topics = result;
            }).catch((err) => {
                
            });

    },

    methods: {
        onsubmit(){
            
            postRequest('/qa/problem/insert',this.problem).then((result) => {
                
            }).catch((err) => {
                
            });
        },
    },
};
</script>

<style scoped>

</style>